package cn.sc.hunter.framework.bean;

import cn.sc.hunter.framework.annotation.RequestMapping;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
 * 封装请求信息
 */
public class Request {
    /**
     * 请求方法
     */
    private String method;

    /**
     * 请求路径
     */
    private String path;

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public Request(String method, String path) {
        this.method = method;
        this.path = path;
    }

    public Request(RequestMapping requestMapping) {
        this.method = requestMapping.method().name();
        this.path = requestMapping.value();
    }

    public Request() {
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    @Override
    public boolean equals(Object obj) {
        return EqualsBuilder.reflectionEquals(this,obj);
    }
}
